package Dao

func Getallconsumer() (error, []Consumer, int64) {
	var consumerdate []Consumer
	var total int64
	err := Db.Table("consumer").Order("consumer_id").Count(&total).Find(&consumerdate).Error
	return err, consumerdate, total
}

func AddConsumer(con Consumer) error{
	err := Db.Table("consumer").Select("consumer_id","consumer_name","consumer_address","consumer_postcode","consumer_phone").Create(&con).Error
	return err
}

func UpdateConsumer(con Consumer) error{
	err := Db.Table("consumer").Where("consumer_id = ?", con.Consumer_id).Updates(&con).Error
	return err
}

func DeleteConsumer(id string) error {
	var consumer []Consumer
	err := Db.Table("consumer").Where("consumer_name = ?", id).Delete(&consumer).Error
	return err
}
